import { ajax } from './ajax'
function getPromise(url) {
    return new Promise((resolve, reject) => {
        ajax(url, suc => {
            resolve(suc)
        }, fail => {
            reject(fail)
        })
    })
}

getPromise('../static/a.json').then(res => {
    console.log(res)
    return getPromise('../static/b.json')
}, err => {
    console.log(err)
})
    .then(res => {
        console.log(res)
        return getPromise('../static/c.json')
    }, err => {
        console.log(err)
    })
    .then(res => {
        console.log(res)
    })

//用async 和await来解决异步回调深渊问题
async function getData(){
    let a = await getPromise('../static/a.json')
    let b = await getPromise('../static/b.json')
    let c = await getPromise('../static/c.json')
    console.log(a) 
    console.log(b)
    console.log(c)
}